package com.syy.statisticalresults;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class GradeMapper extends Mapper<LongWritable, Text, Grade, NullWritable> {
    private Grade grade;

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Grade, NullWritable>.Context context) throws IOException, InterruptedException {
        String s = value.toString();
        String[] split = s.split(" ");
        grade = new Grade(split[0], Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]), Integer.parseInt(split[4]));

        context.write(grade, NullWritable.get());
    }
}
